package com.itheima.Demo03;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
import java.util.SortedSet;

public class Demo服务器端交互 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss  = new ServerSocket(13140);
        System.out.println(1);
        Socket s = ss.accept();
        System.out.println(2);
        while (true){
            //创建输入流;
            InputStream bis = s.getInputStream();
            byte[] arr = new byte[1024];
            int i = bis.read(arr);
            System.out.println("客户端对我说:"+new String(arr,0,i));

            //创建输出流;
            OutputStream bos = s.getOutputStream();
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入内容:");
            String s1 = sc.nextLine();
            bos.write(s1.getBytes());
        }
    }
}
